#include "client_api.h"

// extern int send_register(const char *data, int message_length);

char usr_buffer[2048];
transmit_message usr_tx_transmit_message;
transmit_message usr_rx_transmit_message;

int usr_init() {
    int ret = 0;
    memset(&usr_tx_transmit_message, 0, sizeof(transmit_message));
    return ret;
}

int send_register(const char *data, int message_length) {
    int ret = 0;
    int rev_data_length = 0;

    usr_tx_transmit_message.svcID = REG_FICATION;
    usr_rx_transmit_message.retCode = RET_NG;
    usr_tx_transmit_message.length = message_length;
    memcpy(usr_tx_transmit_message.payload, data, message_length);
    send_request((char *)&usr_tx_transmit_message, sizeof(transmit_message)-2048+message_length,(char*)&usr_rx_transmit_message,&rev_data_length);
    if (usr_rx_transmit_message.retCode == RET_OK) {
        if (usr_rx_transmit_message.length == 0) {
            ret = RET_OK;
            printf("注册成功\n");
        } else {
            ret = RET_NG;
            printf("注册失败\n");
        }
    }
    return ret;
}
